<template>
    <div class="num">
        <div class="content">
            <div class="title">截至{{covData.modifyTime | time}}全国数据统计</div>
            <ul class="wrap">
                <li>
                    <span>较昨日{{covData.confirmedIncr | number}}</span>
                    <div class="bold">{{covData.currentConfirmedCount | division}}</div>
                    <strong>现存确诊</strong>
                </li>
                <li>
                    <span>较昨日{{covData.seriousIncr | number}}</span>
                    <div class="bold">{{covData.suspectedCount | division}}</div>
                    <strong>境外输入</strong>
                </li>
                <li>
                    <span>较昨日{{covData.seriousIncr | number}}</span>
                    <div class="bold">{{covData.seriousCount | division}}</div>
                    <strong>现存无症状</strong>
                </li>
                <li>
                    <span>较昨日{{covData.confirmedIncr | number}}</span>
                    <div class="bold">{{covData.confirmedCount | division}}</div>
                    <strong>累积确诊</strong>
                </li>
                <li>
                    <span>较昨日{{covData.deadIncr | number}}</span>
                    <div class="bold">{{covData.deadCount| division}}</div>
                    <strong>累积死亡</strong>
                </li>
                <li>
                    <span>较昨日{{covData.confirmedIncr | number}}</span>
                    <div class="bold">{{covData.confirmedCount | division}}</div>
                    <strong>累积确诊</strong>
                </li>

            </ul>
        </div>
    </div>
</template>

<script>
    export default {
        name: "CovNumber",
        props: ['covData'],
        // 定义过滤器
        filters: {
            number:function (val) {
                val = val>0?'+'+val:val;
                return val
            },
            // 处理时间的方法
            time:function (num) {
                var date = new Date(num);
                // return date.toLocaleDateString(num);
                var y = date.getFullYear();
                var m = date.getMonth()+1;
                var d = date.getDate();

                return y+'-'+m+'-'+d;
            },
            // 数字转千位
            division: function (num) {
                if(num === undefined) return '';
                return num.toLocaleString();
            }
        },

    }
</script>

<style scoped lang="less">
    .num {
        background-color: #f5f5f5;
        padding-top: 0.2rem;
        .content {
            background-color: #fff;
            min-height: 2rem;
            -webkit-border-radius: 0.2rem 0.2rem 0 0;
            -moz-border-radius: 0.2rem 0.2rem 0 0;
            border-radius: 0.2rem 0.2rem 0 0;
            .title {
                color: #666;
                padding: 0.2rem;
            }
            .wrap {
                display: flex;
                flex-wrap: wrap;
                -webkit-border-radius: 0.1rem;
                -moz-border-radius: 0.1rem;
                border-radius: 0.1rem;
                padding-top: 0.5rem;
                box-shadow:0 0 3px 2px rgba(108, 103, 103, 20%);
                width: 90%;
                margin: 0 auto;
                li {
                    width: 33.333%;
                    text-align: center;
                    margin-bottom: 0.5rem;
                    color: #666666;
                    strong {
                        color: #333;
                    }
                }
                .bold {
                    font-weight: bold;
                    margin: 0.2rem 0;
                }
                li:nth-child(1) .bold {
                    color: red;
                }
                li:nth-child(2) .bold {
                    color: green;
                }
                li:nth-child(3) .bold {
                    color: orange;
                }
                li:nth-child(4) .bold {
                    color: blue;
                }
            }
        }
    }
</style>
